package com.pangolin.pangolinim.service.thread.base;

import android.content.Intent;
import android.os.Bundle;

import com.pangolin.pangolinim.app.BroadcastMsg;
import com.pangolin.pangolinim.app.mainApp;
import com.pangolin.pangolinim.net.MySocket;
import com.pangolin.pangolinim.service.list.ContactList;
import com.pangolin.pangolinim.service.list.SessionList;
import com.pangolin.pangolinim.utils.SPUtil;

public class baseThread extends Thread {
    protected static int mUid = 0;              //用户uid
    protected static String mKey = "";          //用户key
    protected static String mHeadimg = "";      //用户头像
    protected static String mUsername = "";     //用户名

    protected static String usernameTmp;               //临时用户名（修改用户信息时使用）
    protected static String headimgTmp;                //临时用户头像（修改用户信息时使用）

    public static ContactList contacts = new ContactList();     //联系人列表类
    public static SessionList sessions = new SessionList();     //最近会话列表

    protected static MySocket mSocket = new MySocket(); //网络链接句柄

    public static int getmUid(){
        return mUid;
    }

    public static void setmUid(int uid){
        mUid = uid;
    }

    public static String getmKey(){
        return mKey;
    }

    public static void setmKey(String key){
        mKey = key;
    }

    public static MySocket getmSocket(){
        return mSocket;
    }

    /**
     * @ BroadcastSender函数
     * @TODO：广播发送函数，用于将消息发送给UI
     * @param bundle 要传送的数据封包，该封包使用BundleUtil类组装
     */
    public void BroadcastSender(Bundle bundle) {
        Intent intent = new Intent(BroadcastMsg.ACTIVITY_ACTION);
        intent.putExtras(bundle);
        mainApp.getContext().sendBroadcast(intent);
    }
}
